//------------------------------------------------------------
//  Filename: camera_wrapper.v
//   
//  Author  : wlduan@gmail.com
//  Revise  : 2016-10-11 08:40
//  Description: 
//   
//  Copyright (C) 2014, YRBD, Inc. 					      
//  All Rights Reserved.                                       
//-------------------------------------------------------------
//
`timescale 1ns/1ps
 
module CAMERA_WRAPPER ( 
    input  wire          clk_100mhz         , 
    input  wire          resetn             ,  

    input  wire [31:0]   camera_pwr_ctrl    ,
    input  wire [23:0]   camera_dsp_ctrl    ,
    input  wire [31:0]   camera_ctrl        ,
    output wire [15:0]   camera_data_read   ,
    output wire          camera_trans_over  ,

    input  wire          camera_video_en    ,
    input  wire [7:0]    camera_pix_black   ,
    input  wire [15:0]   camera_x_org_cnt   ,
    input  wire [15:0]   camera_y_org_cnt   ,
    input  wire [15:0]   camera_x_scaler    ,
    input  wire [15:0]   camera_y_scaler    ,
    output wire [31:0]   camera_param       , 
    output wire [31:0]   camera_error       ,
    output wire [7:0]    camera_bright      ,      

    input  wire          camera_pclk        , 
    input  wire [7:0]    camera_yuv         , 
    input  wire          camera_h_sync      , 
    input  wire          camera_v_sync      , 
    output wire          camera_pwrdown     ,
    output wire          camera_resetn      ,

    output wire          camera_sclk        ,
    inout  wire          camera_sda         ,
 
    output wire [15:0]   rom_cfgAddr        ,
    input  wire [23:0]   rom_cfgData        ,   

    output wire [15:0]   ext_cfg_state      ,    
   
    output wire [32:0]   camera_din         ,
    output wire          camera_wr_en       ,
    
    output wire [8:0]    coproc_din         ,
    output wire          coproc_wr_en 
);  
//--------------------------------------------------------
CAMERA_CONFIG CAMERA_CONFIG_inst0( 
    .clk_100mhz      ( clk_100mhz        ) ,
    .rst             ( ~resetn           ) ,

    .camera_pwr_ctrl ( camera_pwr_ctrl   ) ,
    .camera_resetn   ( camera_resetn     ) ,
    .camera_pwrdown  ( camera_pwrdown    ) ,

    .iic_addr_size   ( 1'b1              ) ,  //1 -- ov5640      0 -- others
    .iic_devid       ( 8'h78             ) ,  //8'hdc -- bf3003  8'h78 -- ov5640  8'h60 ov2640
    .iic_data_read   ( camera_data_read  ) ,
    .iic_trans_over  ( camera_trans_over ) ,
    .iic_sclk        ( camera_sclk       ) ,
    .iic_sda         ( camera_sda        ) ,

    .rom_cfgAddr     ( rom_cfgAddr       ) ,
    .rom_cfgData     ( rom_cfgData       ) ,

    .ext_cfg_state   ( ext_cfg_state     ) ,
    .ext_iic_ctrl    ( camera_ctrl       ) 
);  
//--------------------------------------------------------
wire camera_filter_en = camera_dsp_ctrl[0];
//--------------------------------------------------------
CAMERA_DC CAMERA_DC_inst0( 
     .clk_100mhz     ( clk_100mhz       ) ,
     .resetn         ( resetn           ) ,

     .camera_pclk    ( camera_pclk      ) ,
     .camera_resetn  ( camera_resetn    ) ,
     .camera_yuv422  ( camera_yuv       ) ,
     .camera_h_sync  ( camera_h_sync    ) ,
     .camera_v_sync  ( camera_v_sync    ) ,
     .camera_param   ( camera_param     ) ,
     .camera_bright  ( camera_bright    ) ,
     .camera_error   ( camera_error     ) ,
     .camera_video_en( camera_video_en  ) ,
  
     .camera_x_scaler( camera_x_scaler  ) ,
     .camera_y_scaler( camera_y_scaler  ) ,
     .x_org_cnt      ( camera_x_org_cnt ) ,
     .y_org_cnt      ( camera_y_org_cnt ) ,

     .vdma_din       ( camera_din       ) ,
     .vdma_v         ( camera_wr_en     ) ,

     .coproc_din     ( coproc_din       ) ,
     .coproc_v       ( coproc_wr_en     )
     
);

endmodule
